import request from '@/utils/request'


// 分类管理相关API
export default {
  // 获取分类树
  getCategoryTree() {
    return request({
      url: '/api/category/tree',
      method: 'get'
    })
  },

  // 创建分类
  createCategory(data) {
    return request({
      url: '/api/category',
      method: 'post',
      data
    })
  },

  // 更新分类
  updateCategory(id, data) {
    return request({
      url: `/api/category/${id}`,
      method: 'put',
      data
    })
  },

  // 删除分类
  deleteCategory(id) {
    return request({
      url: `/api/category/${id}`,
      method: 'delete'
    })
  },
  // 新增：库存操作接口 (出入库)
  updateInventoryOperations(operations) {
    return request({
      url: '/api/inventory/operations',
      method: 'post',
      data: { operations }  // 请求体格式保持一致
    })
  },
  searchCategories(data) {
    return request({
      url: '/api/category/search',
      method: 'post',
      data
    })
  }
}
